package com.wxy.test2.combinationpattern;

import java.util.ArrayList;

public class Folder extends AbstractFile{
    private String name;
    private ArrayList<AbstractFile> fileList = new ArrayList<>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Folder(String name) {
        this.name = name;
    }

    public Folder() {
    }

    @Override
    public void add(AbstractFile file) {
        fileList.add(file);
    }

    @Override
    public void remove(AbstractFile file) {
        fileList.remove(file);
    }

    @Override
    public AbstractFile getChild(int i) {
        return fileList.get(i);
    }

    @Override
    public void killVirus() {
        System.out.println("---------对[folder]" + this.name + "杀毒完毕---------");
        for (AbstractFile list :
                fileList) {
            list.killVirus();
        }
    }
}
